package com.souku.finance.application.ui.invite;

import android.content.Intent;
import android.os.Bundle;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;

import com.souku.finance.application.R;
import com.souku.finance.application.base.BaseTitleBarActivity;
import com.souku.finance.application.http.UrlConstact;
import com.souku.finance.application.ui.mine.EAccountWebActivity;
import com.souku.finance.application.utils.Constant;
import com.souku.finance.application.utils.ShareUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PayWebActivity extends BaseTitleBarActivity {

    @BindView(R.id.web_view)
    WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay_web);
        ButterKnife.bind(this);

        Intent intent = getIntent();
        String dealId = intent.getStringExtra("deailId");
        String couponId = intent.getStringExtra("couponId");
        String incInterestCpId = intent.getStringExtra("incInterestCpId");
        String amount = intent.getStringExtra("amount");
        String accessToken = ShareUtil.getInstance().getString(Constant.Token);
        String userId = ShareUtil.getInstance().getString(Constant.UserId);

        //设置WebView属性，能够执行Javascript脚本
        webView.getSettings().setJavaScriptEnabled(true);

        //加载需要显示的网页
        String str = "userId=" + userId
                + "&dealId=" + dealId
                + "&couponId=" + couponId
                + "&incInterestCpId=" + incInterestCpId
                + "&accessToken=" + accessToken
                + "&amount=" + amount
                + "&appId=APP"
//                + "&staff_id=0"
                + "&error_url=" + "";

        webView.addJavascriptInterface(new AppJavascriptInterface(), "skAppjs");
        webView.postUrl(UrlConstact.PAY_PAGER, str.getBytes());

    }

    @Override
    public void internet() {

    }

    class AppJavascriptInterface {

        @JavascriptInterface
        public void backApp() {
            finish();
        }

    }
}
